package com.yjs.app.trade.web.controller.sys;


import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yjs.app.trade.service.service.sys.AppVersionService;
import com.yjs.app.trade.web.controller.base.BaseController;
import com.yjs.app.trade.web.controller.base.util.Result;

@Controller
@RequestMapping(value = "/app/sys/version")
public class AppVersionController extends BaseController {

	@Autowired
	AppVersionService appVersionService;

	/**
	 * 获取Android最新版本信息
	 * @return
	 */
	@RequestMapping(value = "/getAndroidLastVersion", method = RequestMethod.GET)
	@ResponseBody
	public Object getAndroidLastVersion() {
		Map<String, Object> map = appVersionService.getAndroidLastVersion();
		if (map == null || map.size() == 0) {
			map = new HashMap<String, Object>();
			map.put("VERSION", "1.0.0");
			map.put("MINVERSION", "1.0.0");
		}
		return Result.csuccess(map);
	}
	/**
	 * 获取IOS最新版本信息
	 * @return
	 */
	@RequestMapping(value = "/getIOSLastVersion", method = RequestMethod.GET)
	@ResponseBody
	public Object getIOSLastVersion() {
		return Result.csuccess(appVersionService.getIOSLastVersion());
	}
	/**
	 * 获取Android下载地址
	 * @return
	 */
	@RequestMapping(value = "/downloadAndroidApp", method = RequestMethod.GET)
	@ResponseBody
	public Object downloadAndroidApp() {
		return appVersionService.downloadAndroidApp();
	}
	/**
	 * 获取IOS下载地址
	 * @return
	 */
	@RequestMapping(value = "/downloadIOSApp", method = RequestMethod.GET)
	@ResponseBody
	public Object downloadIOSApp() {
		return appVersionService.downloadIOSApp();
	}
}
